tableView cell 中如果有文本框点击自动滚动不被键盘挡住

tableView cell 中如果有文本框点击自动滚动不被键盘挡住

tableView cell 中如果有文本框点击自动滚动不被键盘挡住

tableView 是继承UIscrollView,所以自然有setContentOffset方法,该方法可以设置tableView的偏移量,那么通过该方法可以设置偏移量让cell不被键盘挡住.

1
2
3
4
WeakSelf
[UIView animateWithDuration:0.3 animations:^{
[weakSelf.tableView setContentOffset:CGPointMake(0, cell.frame.origin.y)];
}];

其中cell.frame.origin.y可以根据需要调节

------本文结束😘感谢阅读------